#ifndef RS485_H
#define RS485_H
#if defined(ARDUINO) && ARDUINO >=100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
 
class RS485
{
  public:
    //SR04(int TrigPin, int EchoPin);
    //float Get();
    int readN();
    int readP();
    int readK();
    uint8_t readBytes(uint8_t *buf, size_t len);
    unsigned int CRC16_2(unsigned char *buf, int len);
    readHumiture_Hum();//RS485土壤传感器(温度&湿度)
    readHumiture_Tem();//RS485土壤传感器(温度&湿度)
    readECPH_Ec();//RS485土壤传感器(温度&湿度&PH)
    readECPH_Ph();//RS485土壤传感器(温度&湿度&PH)
    readHumitureEC_Ec();//RS485土壤传感器(温度&湿度&EC)
    readHumitureEC_Tem();//RS485土壤传感器(温度&湿度&EC)
    readHumitureEC_Hum();//RS485土壤传感器(温度&湿度&EC)
   private:
    //int Trig_Pin;
    //int Echo_Pin;
    uint8_t Com[8] = { 0x01, 0x03, 0x00, 0x1E, 0x00, 0x01, 0xE4, 0x0C };   //氮
    uint8_t Com1[8] = { 0x01, 0x03, 0x00, 0x1F, 0x00, 0x01, 0xB5, 0xCC };  //磷
    uint8_t Com2[8] = { 0x01, 0x03, 0x00, 0x20, 0x00, 0x01, 0x85, 0xC0 };  //钾
    uint8_t Com3[8] = { 0x01, 0x03, 0x00, 0x00, 0x00, 0x02, 0xC4, 0x0B };//RS485土壤传感器(温度&湿度)
    uint8_t Com4[8] = { 0x01, 0x03, 0x00, 0x00, 0x00, 0x04, 0x44, 0x09 };//RS485土壤传感器(温度&湿度&PH)
    uint8_t Com5[8] = { 0x01, 0x03, 0x00, 0x00, 0x00, 0x03, 0x05, 0xCB };//RS485土壤传感器(温度&湿度&EC)
    int N;
    int P;
    int K;
    float tem;
    float hum;
    float ph;
    int ec;
    //float distance;
};
 
#endif